<?php
/** @var ReclamoController $this */
/** @var Reclamo $model */
/** @var AweActiveForm $form */
Util::tsRegisterAssetJs('_form_modal.js');
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
    'id' => 'reclamo-form',
    'type' => 'horizontal',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
        ));
?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4><?php echo Yii::t('AweCrud.app', 'Update') . ' ' . Reclamo::label(); ?> <?php echo CHtml::encode($model) ?></h4>
        </div>

        <div class="modal-body">
            <?php
            echo $form->textFieldGroup(
                    $model, 'asunto', array(
                'wrapperHtmlOptions' => array(
                    'class' => 'col-sm-3 disabled',
                ),
                'widgetOptions' => array(
                    'htmlOptions' => array(
                        'readonly' => $model->asunto ? true : false
                    )
                )
                    )
            );
            ?>
            <?php
            echo $form->textAreaGroup(
                    $model, 'detalle', array(
                'wrapperHtmlOptions' => array(
                    'class' => 'col-sm-5',
                    'disabled' => true
                ),
                'widgetOptions' => array(
                    'htmlOptions' => array(
                        'rows' => 5,
                        'readonly' => $model->detalle ? true : false
                    ),
                )
                    )
            );
            ?>
            <?php
            echo $form->textAreaGroup(
                    $model, 'resolucion', array(
                'wrapperHtmlOptions' => array(
                    'class' => 'col-sm-5',
                ),
                'widgetOptions' => array(
                    'htmlOptions' => array(
                        'rows' => 5,
                        'readonly' => $model->resolucion ? true : false
                    ),
                )
                    )
            );
            if ($model->estado == Reclamo_Constants::ESTADO_RESUELTO) :
                ?>
                <div class="form-group">
                    <label class="col-sm-3 control-label required" for="Reclamo_calificacion">Calificar <span class="required">*</span></label>
                    <div class="col-sm-8 col-sm-9">
                        <input type="hidden" name="Reclamo[calificacion]" id="Reclamo_calificacion">
                        <div class="btn-group" id ="Calificaciones">
                            <?php
//                                            var_dump(Reclamo_Constants::$calificaciones);
                            foreach (Reclamo_Constants::$calificaciones as $calificacion) {
                                if (isset($calificacion['value']) && $calificacion['value'] != '' && $calificacion['value'] != Reclamo_Constants::CALIFICACION_NO_CALIFICADO) {
                                    if (isset($calificacion['type']) && $calificacion['type'] != '') {
                                        $label = '<label data="' . $calificacion['value'] . '" class="btn btn-' . $calificacion['type'] . ' btn-sm">';
                                        if (isset($calificacion['ico']) && $calificacion['ico'] != '') {
                                            $label = $label . '<i class="' . $calificacion['ico'] . '" ></i> ' . $calificacion['value'];
                                        } else {
                                            $label = $label . ' ' . $calificacion['value'];
                                        }
                                        echo ($label . "</label>");
                                    }
                                }
                            }
                            ?>
                        </div>
                        <div class="help-block error" id="Reclamo_calificacion_em_" style="display:none">
                        </div>
                    </div>
                </div>
                <?php
            endif;
            ?>
        </div>

        <div class="modal-footer">
            <?php
            $this->widget('booster.widgets.TbButton', array(
//                'buttonType' => 'submit',
                'id' => 'btn-save-reclamo',
                'context' => 'success',
                'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
                'htmlOptions' => array(
                    'id-form' => "#reclamo-form"
                )
            ));
            ?>
            <?php
            $this->widget(
                    'booster.widgets.TbButton', array(
                'label' => 'Close',
                'url' => '#',
                'htmlOptions' => array('data-dismiss' => 'modal'),
                    )
            );
            ?>

        </div>
    </div>
</div>
<?php $this->endWidget(); ?>